namespace HZY.Core.UploadFile;

public class FileManagerContext
{

    public long MaxFileSizeLimit { get; set; }

    public List<string> FileExtensions { get; set; } = [];

    public bool IsAllowAnyFile { get; set; }

    public string? ServerUrl { get; set; }

    private string _fileDir = string.Empty;
    public string FileDir
    {
        get => _fileDir;
        set
        {
            if (string.IsNullOrWhiteSpace(value))
            {
                _fileDir = "/";
                return;
            }

            if (!value.EndsWith('/') && !value.EndsWith('\\'))
            {
                value += "/";
            }

            _fileDir = value;
        }
    }

    private string _requestPath = string.Empty;

    public string RequestPath
    {
        get => _requestPath;
        set
        {
            if (!value.StartsWith('/') && !value.StartsWith('\\'))
            {
                value = "/" + value;
            }

            if (!value.EndsWith('/') && !value.EndsWith('\\'))
            {
                value += "/";
            }

            _requestPath = value;
        }
    }
}